﻿
Public Class File
    Inherits Indexable




    Public Sub New(ByVal content As String, ByVal format As IndexFormats, ByVal uri As String, ByVal last_modified_time As Date)
        MyBase.New(content, format)
        Me._uri = uri
        Me._last_modified_time = last_modified_time
    End Sub

    ''' <summary>
    ''' Uri of the file
    ''' </summary>
    ''' <remarks>required="true"</remarks>
    Private _uri As String
    ''' <summary>
    ''' Time of last modification
    ''' </summary>
    ''' <remarks>required</remarks>
    Private _last_modified_time As Date



    ''' <summary>
    ''' Title of the file
    ''' </summary>
    Private _title As String
    ''' <summary>
    ''' Author of the file
    ''' </summary>
    Private _author As String




    ''' <summary>
    ''' Author of the file
    ''' </summary>
    Public Property Author() As String
        Get
            Return _author
        End Get
        Set(ByVal value As String)
            _author = value
            SetOtherPropertiesFlag()
        End Set
    End Property

    ''' <summary>
    ''' Time of last modification
    ''' </summary>
    ''' <remarks>required</remarks>
    Public ReadOnly Property Last_modified_time() As Date
        Get
            Return _last_modified_time
        End Get
    End Property
    ''' <summary>
    ''' Title of the file
    ''' </summary>
    Public Property Title() As String
        Get
            Return _title
        End Get
        Set(ByVal value As String)
            _title = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary>
    ''' Uri of the file
    ''' </summary>
    ''' <remarks>required="true"</remarks>
    Public ReadOnly Property Uri() As String
        Get
            Return _uri
        End Get
    End Property

    Protected Overrides Sub AddRequredProperties(ByVal e As [Event])
        MyBase.AddRequredProperties(e)

        e.AddProperty("uri", Me._uri)
        e.AddProperty("last_modified_time", Me._last_modified_time.ToOADate)

    End Sub

    Protected Overrides Sub AddOtherProperties(ByVal e As [Event])
        MyBase.AddOtherProperties(e)


        If Not String.IsNullOrEmpty(_title) Then e.AddProperty("title", _title)
        If Not String.IsNullOrEmpty(_author) Then e.AddProperty("author", _author)


    End Sub


End Class
